﻿using System.Threading.Tasks;
using ControlCenter.ApplicationService;
using ControlCenter.Model.WebApiDto;
using ControlCenter.Operation;
using ControlCenterService.WebApi.Internal;
using Microsoft.AspNetCore.Mvc;
using MingYuanyun.WebApi.Abstractions;

namespace ControlCenterService.WebApi.Controllers
{
    /// <summary>
    /// 机器人执行结果回调Api
    /// </summary>
    [Route("[controller]")]
    public class ResultCallbackController : BasicController
    {
        private readonly IResultCallbackService _resultCallbackService;

        /// <summary>
        /// 类初始化
        /// </summary>
        /// <param name="resultCallbackService"></param>
        public ResultCallbackController(IResultCallbackService resultCallbackService)
        {
            _resultCallbackService = resultCallbackService;
        }

        /// <summary>
        /// 执行结果回调（使用者：ROBOT）
        /// </summary>
        /// <param name="executionCallbackDto">请求参数DTO</param>
        /// <returns></returns>
        [HttpPost]
        [Route("ExecutionPackageCallback")]
        [ClientApiFilter]
        public async Task<HttpRequestResult<bool>> ExecutionPackageCallback([FromBody] ExecutionCallbackDto executionCallbackDto)
        {
            return OkHttpRequestResult(await _resultCallbackService.ExecutionPackageCallback(executionCallbackDto));
        }

        /// <summary>
        /// 安装结果回调（使用者：ROBOT）
        /// </summary>
        /// <param name="installPackageCallbackDto">请求参数DTO</param>
        /// <returns></returns>
        [HttpPost]
        [Route("InstallPackageCallback")]
        [ClientApiFilter]
        public async Task<HttpRequestResult<bool>> InstallPackageCallback([FromBody] InstallPackageCallbackDto installPackageCallbackDto)
        {
            return OkHttpRequestResult(await _resultCallbackService.InstallPackageCallback(installPackageCallbackDto));
        }

    }
}
